<template>
	<view class="my-score-detail">
		<van-cell :title="item.actTitle" :value="scoreTypeStatus+item.score" :label="item.year"
			v-for="(item,index) in scoreList" :key="index" />
		<van-cell v-if="scoreList.length === 0" :title="scoreTypeStatus+'暂无加分'" :key="index" />
	</view>
</template>

<script>
	import {
		mapState,
		mapGetters,
		mapActions
	} from 'vuex'

	import {
		getChuangxinScore,
		getXueyeScore,
		getSixiangScore,
		getWentiScore
	} from '@/config/api.js'
	export default {
		data() {
			return {
				startYear: '',
				endYear: '',
				scoreType: '',
				scoreList: [],
				scoreTypeStatus: ''
			}
		},
		computed: {
			...mapGetters([
				'account'
			])
		},
		methods: {
			async getChuangxinList() {
				let paramsOpt = {
					userAccount: this.account,
					getStatus: 1,
					scoreApprovalStatus: 1,
				}
				let startYear = this.startYear
				let endYear = this.endYear
				startYear && Object.assign(paramsOpt, {
					startYear
				})
				endYear && Object.assign(paramsOpt, {
					endYear
				})

				const cRes = await getChuangxinScore({
					params: paramsOpt
				})
				if (cRes.hasOk) {
					this.scoreList = cRes.data
				}
			},

			async getXueyeList() {
				let paramsOpt = {
					userAccount: this.account,
					getStatus: 1,
					scoreApprovalStatus: 1,
				}
				let startYear = this.startYear
				let endYear = this.endYear
				startYear && Object.assign(paramsOpt, {
					startYear
				})
				endYear && Object.assign(paramsOpt, {
					endYear
				})
				const xRes = await getXueyeScore({
					params: paramsOpt
				})
				if (xRes.hasOk) {
					this.scoreList = xRes.data
				}
			},

			async getSixiangList() {
				let paramsOpt = {
					userAccount: this.account,
					getStatus: 1,
					scoreApprovalStatus: 1,
				}
				let startYear = this.startYear
				let endYear = this.endYear
				startYear && Object.assign(paramsOpt, {
					startYear
				})
				endYear && Object.assign(paramsOpt, {
					endYear
				})
				const sRes = await getSixiangScore({
					params: paramsOpt
				})
				if (sRes.hasOk) {
					this.scoreList = sRes.data
				}
			},

			async getWentiList() {
				let paramsOpt = {
					userAccount: this.account,
					getStatus: 1,
					scoreApprovalStatus: 1,
				}
				let startYear = this.startYear
				let endYear = this.endYear
				startYear && Object.assign(paramsOpt, {
					startYear
				})
				endYear && Object.assign(paramsOpt, {
					endYear
				})
				const wRes = await getWentiScore({
					params: paramsOpt
				})
				if (wRes.hasOk) {
					this.scoreList = wRes.data
				}
			},

			onShow() {
				if (this.scoreType == '0') {
					this.scoreTypeStatus = '创新分'
					this.getChuangxinList()
				} else if (this.scoreType == '1') {
					this.scoreTypeStatus = '学业分'
					this.getXueyeList()
				} else if (this.scoreType == '2') {
					this.scoreTypeStatus = '思想分'
					this.getSixiangList()
				} else if (this.scoreType == '3') {
					this.scoreTypeStatus = '文体分'
					this.getWentiList()
				}
			}


		},
		onLoad: function(option) {
			this.startYear = option.startYear
			this.endYear = option.endYear
			this.scoreType = option.scoreType
		},

	}
</script>

<style lang="scss" scoped>
	.my-score-detail {
		padding: 10px 10px;
	}
</style>